#*****************************************************************************
# DESCRIPTION: Dinotrace make: Makefile pre-configure version
#
# This file is part of Dinotrace.
#
# Author: Wilson Snyder <wsnyder@wsnyder.org>
#
# Code available from: https://www.veripool.org/dinotrace
#
#*****************************************************************************
#
# This file is covered by the GNU public licence.
#
# Dinotrace is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Dinotrace is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dinotrace; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#****************************************************************************/

#### Start of system configuration section. ####

srcdir = @srcdir@

abs_srcdir = @abs_srcdir@
VPATH = @abs_srcdir@

PERL = @PERL@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
LINK = @CC@

CFLAGS = -I. @CFLAGS@ @X_CFLAGS@
OPT = @OPT@
CFLAGS_DBG = -O1 -DDEBUG
ifeq ($(DT_DEBUG),)
 CFLAGS += $(OPT)
else
 CFLAGS += $(CFLAGS_DBG)
endif

CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@
LDFLAGS = @LDFLAGS@
# cygwin needs X_PRE last, paradoxicly
LIBS = @LIBS@ @X_LIBS@ -lXm -lXt -lX11 -lm @X_PRE_LIBS@ @X_EXTRA_LIBS@

prefix = @prefix@

#### End of system configuration section. ####

ifeq ($(VERILATOR_AUTHOR_SITE),1)	# Local... Else don't burden users
CPPFLAGS += -Wall -Werror
endif

#### Rules

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@

#### Top level

all: dinotrace

clean mostlyclean distclean maintainer-clean::
	rm -f *.o

distclean maintainer-clean::
	rm -f Makefile config.h

maintainer-clean::
	rm -f dinodoc.h dist_date.h

maintainer-copy::

#### Modules

SRCS = dt_binary.c dt_config.c dt_cursor.c dt_customize.c dt_dispmgr.c dt_draw.c \
	dt_file.c dt_grid.c dt_print.c dt_signal.c dt_util.c \
	dt_window.c dt_value.c dt_verilog.c dt_socket.c dinotrace.c dt_icon.c \
	dt_ascii.c

OBJS = dt_binary.o dt_config.o dt_cursor.o dt_customize.o dt_dispmgr.o dt_draw.o \
	dt_file.o dt_grid.o dt_print.o dt_signal.o dt_util.o \
	dt_window.o dt_value.o dt_verilog.o dt_socket.o dinotrace.o dt_icon.o \
	dt_ascii.o

COMMON_HDRS = dinotrace.h functions.h
ALL_HDRS = $(COMMON_HDRS) bintradef.h dist_date.h dt_post.h dinodoc.h

#### Top executable

dinotrace: $(OBJS) Makefile
	$(LINK) $(LDFLAGS) -o $@ $(LINKOPT) $(OBJS) $(LIBS)

#### Derrived files

dinodoc.h: ../dinotrace.txt dinodoc.pl
	$(PERL) $(abs_srcdir)/dinodoc.pl <../dinotrace.txt >dinodoc.h

../dinotrace.txt:
	(cd .. ; $(MAKE) dinotrace.txt)

# No dependancy on other files in case user extracted without preserving
# date stamps
dist_date.h:
	$(PERL) $(abs_srcdir)/dist_date.pl

#### Object links

dinotrace.o: dinotrace.c $(COMMON_HDRS) dist_date.h

dt_binary.o: dt_binary.c $(COMMON_HDRS) bintradef.h

dt_config.o: dt_config.c $(COMMON_HDRS)

dt_cursor.o: dt_cursor.c $(COMMON_HDRS)

dt_customize.o: dt_customize.c $(COMMON_HDRS)

dt_dispmgr.o: dt_dispmgr.c $(COMMON_HDRS)

dt_draw.o: dt_draw.c $(COMMON_HDRS)

dt_file.o: dt_file.c $(COMMON_HDRS) dinodoc.h

dt_grid.o: dt_grid.c $(COMMON_HDRS)

dt_icon.o: dt_icon.c $(COMMON_HDRS)

dt_print.o: dt_print.c $(COMMON_HDRS) dt_post.h

dt_signal.o:	dt_signal.c $(COMMON_HDRS)

dt_socket.o:	dt_socket.c $(COMMON_HDRS)

dt_util.o:	dt_util.c $(COMMON_HDRS)

dt_window.o:	dt_window.c $(COMMON_HDRS)

dt_value.o: 	dt_value.c $(COMMON_HDRS)

dt_verilog.o:	dt_verilog.c $(COMMON_HDRS)

dt_ascii.o:	dt_ascii.c $(COMMON_HDRS)

